Add API output skin
[lhc/web/wiklou.git] / includes / Setup.php
1 <?php
2 /**
3 * Include most things that are needed to make %MediaWiki work.
4 *
5 * This file is included by WebStart.php and doMaintenance.php so that both
6 * web and maintenance scripts share a final set up phase to include necessary
7 * files and create global object variables.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * This file is not a valid entry point, perform no further processing unless
29 * MEDIAWIKI is defined
30 */
31 if ( !defined( 'MEDIAWIKI' ) ) {
32 exit( 1 );
33 }
34
35 $fname = 'Setup.php';
36 wfProfileIn( $fname );
37 wfProfileIn( $fname . '-defaults' );
38
39 // Check to see if we are at the file scope
40 if ( !isset( $wgVersion ) ) {
41 echo "Error, Setup.php must be included from the file scope, after DefaultSettings.php\n";
42 die( 1 );
43 }
44
45 // Set various default paths sensibly...
46
47 if ( $wgScript === false ) {
48 $wgScript = "$wgScriptPath/index$wgScriptExtension";
49 }
50 if ( $wgLoadScript === false ) {
51 $wgLoadScript = "$wgScriptPath/load$wgScriptExtension";
52 }
53
54 if ( $wgArticlePath === false ) {
55 if ( $wgUsePathInfo ) {
56 $wgArticlePath = "$wgScript/$1";
57 } else {
58 $wgArticlePath = "$wgScript?title=$1";
59 }
60 }
61
62 if ( !empty( $wgActionPaths ) && !isset( $wgActionPaths['view'] ) ) {
63 // 'view' is assumed the default action path everywhere in the code
64 // but is rarely filled in $wgActionPaths
65 $wgActionPaths['view'] = $wgArticlePath;
66 }
67
68 if ( $wgStylePath === false ) {
69 $wgStylePath = "$wgScriptPath/skins";
70 }
71 if ( $wgLocalStylePath === false ) {
72 $wgLocalStylePath = "$wgScriptPath/skins";
73 }
74 if ( $wgStyleDirectory === false ) {
75 $wgStyleDirectory = "$IP/skins";
76 }
77 if ( $wgExtensionAssetsPath === false ) {
78 $wgExtensionAssetsPath = "$wgScriptPath/extensions";
79 }
80
81 if ( $wgLogo === false ) {
82 $wgLogo = "$wgStylePath/common/images/wiki.png";
83 }
84
85 if ( $wgUploadPath === false ) {
86 $wgUploadPath = "$wgScriptPath/images";
87 }
88 if ( $wgUploadDirectory === false ) {
89 $wgUploadDirectory = "$IP/images";
90 }
91 if ( $wgReadOnlyFile === false ) {
92 $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
93 }
94 if ( $wgFileCacheDirectory === false ) {
95 $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
96 }
97 if ( $wgDeletedDirectory === false ) {
98 $wgDeletedDirectory = "{$wgUploadDirectory}/deleted";
99 }
100
101 if ( $wgGitInfoCacheDirectory === false && $wgCacheDirectory !== false ) {
102 $wgGitInfoCacheDirectory = "{$wgCacheDirectory}/gitinfo";
103 }
104
105 // Fix path to icon images after they were moved in 1.24
106 if ( $wgRightsIcon ) {
107 $wgRightsIcon = str_replace(
108 "{$wgStylePath}/common/images/",
109 "{$wgScriptPath}/assets/licenses/",
110 $wgRightsIcon
111 );
112 }
113
114 if ( isset( $wgFooterIcons['copyright'] )
115 && isset( $wgFooterIcons['copyright']['copyright'] )
116 && $wgFooterIcons['copyright']['copyright'] === array()
117 ) {
118 if ( $wgCopyrightIcon ) {
119 $wgFooterIcons['copyright']['copyright'] = $wgCopyrightIcon;
120 } elseif ( $wgRightsIcon || $wgRightsText ) {
121 $wgFooterIcons['copyright']['copyright'] = array(
122 'url' => $wgRightsUrl,
123 'src' => $wgRightsIcon,
124 'alt' => $wgRightsText,
125 );
126 } else {
127 unset( $wgFooterIcons['copyright']['copyright'] );
128 }
129 }
130
131 if ( isset( $wgFooterIcons['poweredby'] )
132 && isset( $wgFooterIcons['poweredby']['mediawiki'] )
133 && $wgFooterIcons['poweredby']['mediawiki']['src'] === null
134 ) {
135 $wgFooterIcons['poweredby']['mediawiki']['src'] =
136 "$wgScriptPath/assets/poweredby_mediawiki_88x31.png";
137 }
138
139 /**
140 * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
141 * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
142 *
143 * Note that this is the definition of editinterface and it can be granted to
144 * all users if desired.
145 */
146 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
147
148 /**
149 * The canonical names of namespaces 6 and 7 are, as of v1.14, "File"
150 * and "File_talk". The old names "Image" and "Image_talk" are
151 * retained as aliases for backwards compatibility.
152 */
153 $wgNamespaceAliases['Image'] = NS_FILE;
154 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
155
156 /**
157 * Initialise $wgLockManagers to include basic FS version
158 */
159 $wgLockManagers[] = array(
160 'name' => 'fsLockManager',
161 'class' => 'FSLockManager',
162 'lockDirectory' => "{$wgUploadDirectory}/lockdir",
163 );
164 $wgLockManagers[] = array(
165 'name' => 'nullLockManager',
166 'class' => 'NullLockManager',
167 );
168
169 /**
170 * Initialise $wgLocalFileRepo from backwards-compatible settings
171 */
172 if ( !$wgLocalFileRepo ) {
173 $wgLocalFileRepo = array(
174 'class' => 'LocalRepo',
175 'name' => 'local',
176 'directory' => $wgUploadDirectory,
177 'scriptDirUrl' => $wgScriptPath,
178 'scriptExtension' => $wgScriptExtension,
179 'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
180 'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
181 'thumbScriptUrl' => $wgThumbnailScriptPath,
182 'transformVia404' => !$wgGenerateThumbnailOnParse,
183 'deletedDir' => $wgDeletedDirectory,
184 'deletedHashLevels' => $wgHashedUploadDirectory ? 3 : 0
185 );
186 }
187 /**
188 * Initialise shared repo from backwards-compatible settings
189 */
190 if ( $wgUseSharedUploads ) {
191 if ( $wgSharedUploadDBname ) {
192 $wgForeignFileRepos[] = array(
193 'class' => 'ForeignDBRepo',
194 'name' => 'shared',
195 'directory' => $wgSharedUploadDirectory,
196 'url' => $wgSharedUploadPath,
197 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
198 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
199 'transformVia404' => !$wgGenerateThumbnailOnParse,
200 'dbType' => $wgDBtype,
201 'dbServer' => $wgDBserver,
202 'dbUser' => $wgDBuser,
203 'dbPassword' => $wgDBpassword,
204 'dbName' => $wgSharedUploadDBname,
205 'dbFlags' => ( $wgDebugDumpSql ? DBO_DEBUG : 0 ) | DBO_DEFAULT,
206 'tablePrefix' => $wgSharedUploadDBprefix,
207 'hasSharedCache' => $wgCacheSharedUploads,
208 'descBaseUrl' => $wgRepositoryBaseUrl,
209 'fetchDescription' => $wgFetchCommonsDescriptions,
210 );
211 } else {
212 $wgForeignFileRepos[] = array(
213 'class' => 'FileRepo',
214 'name' => 'shared',
215 'directory' => $wgSharedUploadDirectory,
216 'url' => $wgSharedUploadPath,
217 'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
218 'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
219 'transformVia404' => !$wgGenerateThumbnailOnParse,
220 'descBaseUrl' => $wgRepositoryBaseUrl,
221 'fetchDescription' => $wgFetchCommonsDescriptions,
222 );
223 }
224 }
225 if ( $wgUseInstantCommons ) {
226 $wgForeignFileRepos[] = array(
227 'class' => 'ForeignAPIRepo',
228 'name' => 'wikimediacommons',
229 'apibase' => WebRequest::detectProtocol() === 'https' ?
230 'https://commons.wikimedia.org/w/api.php' :
231 'http://commons.wikimedia.org/w/api.php',
232 'hashLevels' => 2,
233 'fetchDescription' => true,
234 'descriptionCacheExpiry' => 43200,
235 'apiThumbCacheExpiry' => 86400,
236 );
237 }
238 /*
239 * Add on default file backend config for file repos.
240 * FileBackendGroup will handle initializing the backends.
241 */
242 if ( !isset( $wgLocalFileRepo['backend'] ) ) {
243 $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
244 }
245 foreach ( $wgForeignFileRepos as &$repo ) {
246 if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
247 $repo['directory'] = $wgUploadDirectory; // b/c
248 }
249 if ( !isset( $repo['backend'] ) ) {
250 $repo['backend'] = $repo['name'] . '-backend';
251 }
252 }
253 unset( $repo ); // no global pollution; destroy reference
254
255 if ( $wgRCFilterByAge ) {
256 // Trim down $wgRCLinkDays so that it only lists links which are valid
257 // as determined by $wgRCMaxAge.
258 // Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
259 sort( $wgRCLinkDays );
260
261 // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
262 for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
263 // @codingStandardsIgnoreEnd
264 if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
265 $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
266 break;
267 }
268 }
269 }
270
271 if ( $wgSkipSkin ) {
272 $wgSkipSkins[] = $wgSkipSkin;
273 }
274
275 // Register skins
276 // Use a closure to avoid leaking into global state
277 call_user_func( function () use ( $wgValidSkinNames ) {
278 $factory = SkinFactory::getDefaultInstance();
279 foreach ( $wgValidSkinNames as $name => $skin ) {
280 $factory->register( $name, $skin, function () use ( $name, $skin ) {
281 $class = "Skin$skin";
282 return new $class( $name );
283 } );
284 }
285 // Register a hidden "fallback" skin
286 $factory->register( 'fallback', 'Fallback', function () {
287 return new SkinFallback;
288 } );
289 // Register a hidden skin for api output
290 $factory->register( 'apioutput', 'ApiOutput', function () {
291 return new SkinApi;
292 } );
293 } );
294 $wgSkipSkins[] = 'fallback';
295 $wgSkipSkins[] = 'apioutput';
296
297 if ( $wgLocalInterwiki ) {
298 array_unshift( $wgLocalInterwikis, $wgLocalInterwiki );
299 }
300
301 // Set default shared prefix
302 if ( $wgSharedPrefix === false ) {
303 $wgSharedPrefix = $wgDBprefix;
304 }
305
306 if ( !$wgCookiePrefix ) {
307 if ( $wgSharedDB && $wgSharedPrefix && in_array( 'user', $wgSharedTables ) ) {
308 $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
309 } elseif ( $wgSharedDB && in_array( 'user', $wgSharedTables ) ) {
310 $wgCookiePrefix = $wgSharedDB;
311 } elseif ( $wgDBprefix ) {
312 $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
313 } else {
314 $wgCookiePrefix = $wgDBname;
315 }
316 }
317 $wgCookiePrefix = strtr( $wgCookiePrefix, '=,; +."\'\\[', '__________' );
318
319 if ( $wgEnableEmail ) {
320 $wgUseEnotif = $wgEnotifUserTalk || $wgEnotifWatchlist;
321 } else {
322 // Disable all other email settings automatically if $wgEnableEmail
323 // is set to false. - bug 63678
324 $wgAllowHTMLEmail = false;
325 $wgEmailAuthentication = false; // do not require auth if you're not sending email anyway
326 $wgEnableUserEmail = false;
327 $wgEnotifFromEditor = false;
328 $wgEnotifImpersonal = false;
329 $wgEnotifMaxRecips = 0;
330 $wgEnotifMinorEdits = false;
331 $wgEnotifRevealEditorAddress = false;
332 $wgEnotifUseJobQ = false;
333 $wgEnotifUseRealName = false;
334 $wgEnotifUserTalk = false;
335 $wgEnotifWatchlist = false;
336 unset( $wgGroupPermissions['user']['sendemail'] );
337 $wgUseEnotif = false;
338 $wgUserEmailUseReplyTo = false;
339 $wgUsersNotifiedOnAllChanges = array();
340 }
341
342 // Doesn't make sense to have if disabled.
343 if ( !$wgEnotifMinorEdits ) {
344 $wgHiddenPrefs[] = 'enotifminoredits';
345 }
346
347 if ( $wgMetaNamespace === false ) {
348 $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
349 }
350
351 // Default value is either the suhosin limit or -1 for unlimited
352 if ( $wgResourceLoaderMaxQueryLength === false ) {
353 $maxValueLength = ini_get( 'suhosin.get.max_value_length' );
354 $wgResourceLoaderMaxQueryLength = $maxValueLength > 0 ? $maxValueLength : -1;
355 }
356
357 /**
358 * Definitions of the NS_ constants are in Defines.php
359 * @private
360 */
361 $wgCanonicalNamespaceNames = array(
362 NS_MEDIA => 'Media',
363 NS_SPECIAL => 'Special',
364 NS_TALK => 'Talk',
365 NS_USER => 'User',
366 NS_USER_TALK => 'User_talk',
367 NS_PROJECT => 'Project',
368 NS_PROJECT_TALK => 'Project_talk',
369 NS_FILE => 'File',
370 NS_FILE_TALK => 'File_talk',
371 NS_MEDIAWIKI => 'MediaWiki',
372 NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
373 NS_TEMPLATE => 'Template',
374 NS_TEMPLATE_TALK => 'Template_talk',
375 NS_HELP => 'Help',
376 NS_HELP_TALK => 'Help_talk',
377 NS_CATEGORY => 'Category',
378 NS_CATEGORY_TALK => 'Category_talk',
379 );
380
381 /// @todo UGLY UGLY
382 if ( is_array( $wgExtraNamespaces ) ) {
383 $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
384 }
385
386 // These are now the same, always
387 // To determine the user language, use $wgLang->getCode()
388 $wgContLanguageCode = $wgLanguageCode;
389
390 // Easy to forget to falsify $wgShowIPinHeader for static caches.
391 // If file cache or squid cache is on, just disable this (DWIMD).
392 // Do the same for $wgDebugToolbar.
393 if ( $wgUseFileCache || $wgUseSquid ) {
394 $wgShowIPinHeader = false;
395 $wgDebugToolbar = false;
396 }
397
398 // We always output HTML5 since 1.22, overriding these is no longer supported
399 // we set them here for extensions that depend on its value.
400 $wgHtml5 = true;
401 $wgXhtmlDefaultNamespace = 'http://www.w3.org/1999/xhtml';
402 $wgJsMimeType = 'text/javascript';
403
404 if ( !$wgHtml5Version && $wgAllowRdfaAttributes ) {
405 // see http://www.w3.org/TR/rdfa-in-html/#document-conformance
406 if ( $wgMimeType == 'application/xhtml+xml' ) {
407 $wgHtml5Version = 'XHTML+RDFa 1.0';
408 } else {
409 $wgHtml5Version = 'HTML+RDFa 1.0';
410 }
411 }
412
413 // Blacklisted file extensions shouldn't appear on the "allowed" list
414 $wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
415
416 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
417 // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
418 $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
419 // @codingStandardsIgnoreEnd
420 }
421
422 if ( $wgNewUserLog ) {
423 // Add a new log type
424 $wgLogTypes[] = 'newusers';
425 $wgLogNames['newusers'] = 'newuserlogpage';
426 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
427 $wgLogActionsHandlers['newusers/newusers'] = 'NewUsersLogFormatter';
428 $wgLogActionsHandlers['newusers/create'] = 'NewUsersLogFormatter';
429 $wgLogActionsHandlers['newusers/create2'] = 'NewUsersLogFormatter';
430 $wgLogActionsHandlers['newusers/byemail'] = 'NewUsersLogFormatter';
431 $wgLogActionsHandlers['newusers/autocreate'] = 'NewUsersLogFormatter';
432 }
433
434 if ( $wgPageLanguageUseDB ) {
435 $wgLogTypes[] = 'pagelang';
436 $wgLogActionsHandlers['pagelang/pagelang'] = 'PageLangLogFormatter';
437 }
438
439 if ( $wgCookieSecure === 'detect' ) {
440 $wgCookieSecure = ( WebRequest::detectProtocol() === 'https' );
441 }
442
443 // Back compatibility for $wgRateLimitLog deprecated with 1.23
444 if ( $wgRateLimitLog && !array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) {
445 $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog;
446 }
447
448 if ( $wgProfileOnly ) {
449 $wgDebugLogGroups['profileoutput'] = $wgDebugLogFile;
450 $wgDebugLogFile = '';
451 }
452
453 wfProfileOut( $fname . '-defaults' );
454
455 // Disable MWDebug for command line mode, this prevents MWDebug from eating up
456 // all the memory from logging SQL queries on maintenance scripts
457 global $wgCommandLineMode;
458 if ( $wgDebugToolbar && !$wgCommandLineMode ) {
459 wfProfileIn( $fname . '-debugtoolbar' );
460 MWDebug::init();
461 wfProfileOut( $fname . '-debugtoolbar' );
462 }
463
464 if ( !class_exists( 'AutoLoader' ) ) {
465 require_once "$IP/includes/AutoLoader.php";
466 }
467
468 wfProfileIn( $fname . '-exception' );
469 MWExceptionHandler::installHandler();
470 wfProfileOut( $fname . '-exception' );
471
472 wfProfileIn( $fname . '-includes' );
473 require_once "$IP/includes/normal/UtfNormalUtil.php";
474 require_once "$IP/includes/GlobalFunctions.php";
475 require_once "$IP/includes/normal/UtfNormalDefines.php";
476 wfProfileOut( $fname . '-includes' );
477
478 wfProfileIn( $fname . '-defaults2' );
479
480 if ( $wgCanonicalServer === false ) {
481 $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
482 }
483
484 // Set server name
485 $serverParts = wfParseUrl( $wgCanonicalServer );
486 if ( $wgServerName !== false ) {
487 wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
488 . 'not customized. Overwriting $wgServerName.' );
489 }
490 $wgServerName = $serverParts['host'];
491 unset( $serverParts );
492
493 // Set defaults for configuration variables
494 // that are derived from the server name by default
495 if ( $wgEmergencyContact === false ) {
496 $wgEmergencyContact = 'wikiadmin@' . $wgServerName;
497 }
498
499 if ( $wgPasswordSender === false ) {
500 $wgPasswordSender = 'apache@' . $wgServerName;
501 }
502
503 if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
504 $wgSecureLogin = false;
505 wfWarn( 'Secure login was enabled on a server that only supports '
506 . 'HTTP or HTTPS. Disabling secure login.' );
507 }
508
509 // Now that GlobalFunctions is loaded, set defaults that depend
510 // on it.
511 if ( $wgTmpDirectory === false ) {
512 wfProfileIn( $fname . '-tempDir' );
513 $wgTmpDirectory = wfTempDir();
514 wfProfileOut( $fname . '-tempDir' );
515 }
516
517 wfProfileOut( $fname . '-defaults2' );
518 wfProfileIn( $fname . '-misc1' );
519
520 // Raise the memory limit if it's too low
521 wfMemoryLimit();
522
523 /**
524 * Set up the timezone, suppressing the pseudo-security warning in PHP 5.1+
525 * that happens whenever you use a date function without the timezone being
526 * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
527 */
528 if ( is_null( $wgLocaltimezone ) ) {
529 wfSuppressWarnings();
530 $wgLocaltimezone = date_default_timezone_get();
531 wfRestoreWarnings();
532 }
533
534 date_default_timezone_set( $wgLocaltimezone );
535 if ( is_null( $wgLocalTZoffset ) ) {
536 $wgLocalTZoffset = date( 'Z' ) / 60;
537 }
538
539 // Useful debug output
540 if ( $wgCommandLineMode ) {
541 $wgRequest = new FauxRequest( array() );
542
543 wfDebug( "\n\nStart command line script $self\n" );
544 } else {
545 // Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
546 $wgRequest = new WebRequest;
547
548 $debug = "\n\nStart request {$wgRequest->getMethod()} {$wgRequest->getRequestURL()}\n";
549
550 if ( $wgDebugPrintHttpHeaders ) {
551 $debug .= "HTTP HEADERS:\n";
552
553 foreach ( $wgRequest->getAllHeaders() as $name => $value ) {
554 $debug .= "$name: $value\n";
555 }
556 }
557 wfDebug( $debug );
558 }
559
560 wfProfileOut( $fname . '-misc1' );
561 wfProfileIn( $fname . '-memcached' );
562
563 $wgMemc = wfGetMainCache();
564 $messageMemc = wfGetMessageCacheStorage();
565 $parserMemc = wfGetParserCacheStorage();
566 $wgLangConvMemc = wfGetLangConverterCacheStorage();
567
568 wfDebugLog( 'caches', 'main: ' . get_class( $wgMemc ) .
569 ', message: ' . get_class( $messageMemc ) .
570 ', parser: ' . get_class( $parserMemc ) );
571
572 wfProfileOut( $fname . '-memcached' );
573
574 // Most of the config is out, some might want to run hooks here.
575 wfRunHooks( 'SetupAfterCache' );
576
577 wfProfileIn( $fname . '-session' );
578
579 if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
580 // If session.auto_start is there, we can't touch session name
581 if ( !wfIniGetBool( 'session.auto_start' ) ) {
582 session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
583 }
584
585 if ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix . 'Token'] ) ) {
586 wfSetupSession();
587 }
588 }
589
590 wfProfileOut( $fname . '-session' );
591 wfProfileIn( $fname . '-globals' );
592
593 /**
594 * @var Language $wgContLang
595 */
596 $wgContLang = Language::factory( $wgLanguageCode );
597 $wgContLang->initEncoding();
598 $wgContLang->initContLang();
599
600 // Now that variant lists may be available...
601 $wgRequest->interpolateTitle();
602
603 /**
604 * @var User $wgUser
605 */
606 $wgUser = RequestContext::getMain()->getUser(); // BackCompat
607
608 /**
609 * @var Language $wgLang
610 */
611 $wgLang = new StubUserLang;
612
613 /**
614 * @var OutputPage $wgOut
615 */
616 $wgOut = RequestContext::getMain()->getOutput(); // BackCompat
617
618 /**
619 * @var Parser $wgParser
620 */
621 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
622
623 if ( !is_object( $wgAuth ) ) {
624 $wgAuth = new AuthPlugin;
625 wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
626 }
627
628 /**
629 * @var Title $wgTitle
630 */
631 $wgTitle = null;
632
633 /**
634 * @deprecated since 1.24 Use DeferredUpdates::addUpdate instead
635 * @var array
636 */
637 $wgDeferredUpdateList = array();
638
639 wfProfileOut( $fname . '-globals' );
640 wfProfileIn( $fname . '-extensions' );
641
642 // Extension setup functions for extensions other than skins
643 // Entries should be added to this variable during the inclusion
644 // of the extension file. This allows the extension to perform
645 // any necessary initialisation in the fully initialised environment
646 foreach ( $wgExtensionFunctions as $func ) {
647 // Allow closures in PHP 5.3+
648 if ( is_object( $func ) && $func instanceof Closure ) {
649 $profName = $fname . '-extensions-closure';
650 } elseif ( is_array( $func ) ) {
651 if ( is_object( $func[0] ) ) {
652 $profName = $fname . '-extensions-' . get_class( $func[0] ) . '::' . $func[1];
653 } else {
654 $profName = $fname . '-extensions-' . implode( '::', $func );
655 }
656 } else {
657 $profName = $fname . '-extensions-' . strval( $func );
658 }
659
660 wfProfileIn( $profName );
661 call_user_func( $func );
662 wfProfileOut( $profName );
663 }
664
665 wfDebug( "Fully initialised\n" );
666 $wgFullyInitialised = true;
667
668 wfProfileOut( $fname . '-extensions' );
669 wfProfileOut( $fname );